<template>
  <div>
    <el-button icon="el-icon-back" circle @click="back"></el-button>
    <el-form ref="form" :model="form" status-icon :rules="rules" label-width="140px">
      <el-form-item label="鉴定方式信息描述" prop="identifytext">
        <el-input v-model="form.identifytext"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="upd">更新</el-button>
        <el-button @click="cancel">恢复</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  name: "EditUser",
  qid:'',
  data(){
    return{
      temp:[],
      form: {
        identifytext: '',
      },
      rules: {
        identifytext: [
          {required: true, message: '描述信息不可为空', trigger: 'blur'}
        ]
      },
    }
  },
  created: function() {
    this.qid=this.$route.params.qid;
  },
  beforeRouteEnter: (to,from,next) => {
    console.log('进入路由之前');//加载数据
    next(vm => {
      vm.selectinfo();
    })
  },
  methods:{
    back: function (){
      this.$router.push("/func/IidentifyProvide");
    },
    upd:function(){
      this.axios({
        method:"post",
        headers: { 'content-type': 'application/json' },
        url: "http://evidence.frogking.cn/identifyUserController/updateIdentifyProvide",
        params:{
          token:localStorage.getItem("token_only"),
          qid: this.qid,
          identifyText: this.form.identifytext,
        }
      }).then(res=>{
        console.log(res)
        if(res["data"]["code"]==='300'){
          this.$router.push('/func/IidentifyProvide')
        }
        else if(res["data"]["code"]==='301'){
          this.$alert('系统错误！更新异常！', '错误提示', {
            confirmButtonText: '确定',
            callback: action => {
              this.$router.push("/func/IidentifyProvide");
            }
          });
        }
        else if(res["data"]["code"]==='309'){
          this.$alert('鉴定机构不存在！更新异常！', '错误提示', {
            confirmButtonText: '确定',
            callback: action => {
              this.$router.push("/func/IidentifyProvide");
            }
          });
        }
        else if(res["data"]["code"]==='000'){
          this.$alert('token失效', '错误提示', {
            confirmButtonText: '确定',
            callback: action => {
              this.$router.push("/login");
              localStorage.removeItem("token_only");
            }
          });
        }
        else if(res["data"]["code"]==='001'){
          this.$alert('token权限不满足，禁止操作', '错误提示', {
            confirmButtonText: '确定'
          });
        }
        else if(res["data"]["code"]==='002'){
          this.$alert('token权限不满足，禁止操作', '错误提示', {
            confirmButtonText: '确定'
          });
        }
      }).catch(function (error) {
        console.log(error);
      });
    },
    cancel:function (){
        this.form.identifytext='';
    }
  }

}
</script>
<style scoped>

</style>
